//
//  AgreementView.m
//  ZiJinLian
//
//  Created by 🐛 on 2017/6/28.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "AgreementView.h"

@implementation AgreementView
-(id)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self) {
        self.backgroundColor=[UIColor clearColor];
        
        
        UITapGestureRecognizer* singleRecognizer;
        singleRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fingerTapped)];
        //点击的次数
        singleRecognizer.numberOfTapsRequired = 1; // 单击
        
        //给self.view添加一个手势监测；
        
        UILabel *label=[[UILabel alloc]init];
        //label.text=@"注册即默认同意《用户注册协议》";
        label.textColor=TextColor9;
        label.textAlignment=NSTextAlignmentCenter;
        label.font=[UIFont systemFontOfSize:12];
        label.frame=CGRectMake(0, 0, MainW, 20);
        NSString *str1 = MyString(@"注册即默认同意");
        long len1 = [str1 length];
        NSString *nameStr =MyString(@"《用户注册协议》");
        NSString *str = [NSString stringWithFormat:@"%@%@",MyString(@"注册即默认同意"),nameStr];
        long len2 = [nameStr length];
        NSMutableAttributedString *str2 = [[NSMutableAttributedString alloc]initWithString:str];
        [str2 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#cf0000"] range:NSMakeRange(len1,len2)];
        [str2 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12.0f] range:NSMakeRange(len1,len2)];
        label.attributedText = str2;
        label.numberOfLines = 0;
        [self addSubview:label];
        [self addGestureRecognizer:singleRecognizer];
        
        
        
        
    }
    return self;
}
-(void)fingerTapped{
    [_delegate AgreementDelegateClick];
}
@end
